home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / demo / gcp_24.exe / FILOPEN.BA_ / FILOPEN.BA
Text File  |  1994-04-27  |  2KB  |  57 lines

  1. Declare Function WritePrivateProfileString Lib "Kernel" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lplFileName As String) As Integer
  2. Declare Function GetPrivateProfileString Lib "Kernel" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Integer, ByVal lpFileName As String) As Integer
  3. Declare Function GetPrivateProfileInt Lib "Kernel" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal nDefault As Integer, ByVal lpFileName As String) As Integer
  4.  
  5. Sub LoadConfig (TypeLoad As Integer)  'type can be new or previous session
  6. On Error GoTo LoadConfigCancelError
  7.     ' query user for configuration name
  8.     Dim Tmp As String * 80
  9.     Dim Path As String
  10.     Dim Temp As String
  11.  
  12.     Path = CurDir$
  13.     FIndex = FindFreeIndex()
  14.     FState(FIndex).Session = NewSession.Text1.Text
  15.     FState(FIndex).NewFlag = True
  16.     SessionName = FState(FIndex).Session
  17.     FState(FIndex).Path = Path
  18.     Temp = Path
  19.     'if path is root then tack on a slash
  20.     If Right$(Temp, 1) = ":" Then Temp = Temp & "\"
  21.     suc = WritePrivateProfileString(AppName, "LastSessionPath", Temp, IniFile)
  22.     Document(FIndex).Tag = FIndex
  23.     Document(FIndex).WindowState = 0
  24.     Document(FIndex).Caption = SessionName & " - loading new session..."
  25.     suc = GetPrivateProfileString("CommPort", "CommSettings", frmMDI.ActiveForm.VT1.CommSettings, Tmp, 80, IniFile)
  26.     Temp = Left$(Tmp, InStr(Tmp, Chr$(0)) - 1)
  27.     Document(FIndex).VT1.CommSettings = Temp
  28.     Document(FIndex).VT1.FlowControl = GetPrivateProfileInt("CommPort", "FlowControl", frmMDI.ActiveForm.VT1.FlowControl, IniFile)
  29.  
  30.     
  31.     ' set the Notepad's Session name
  32.     SessionName = FState(FIndex).Session
  33.     ' reset the dirty flag
  34.     FState(FIndex).Dirty = False
  35.  
  36.     'restore directory and drive
  37.     ChDir Path
  38.     ChDrive Left$(Path, 2)
  39.  
  40.  
  41.     Exit Sub
  42.  
  43. LoadConfigCancelError:
  44.     ChDir Path
  45.     ChDrive Left$(Path, 2)
  46.  
  47.     If Err = 32755 Then 'user typed cancel/esc
  48.     Exit Sub
  49.     Else
  50.     Msg% = MsgBox(Error$ & Chr$(10) & "Error Code #" & Format$(Err), 49, "VT220 for Workgroups")
  51.     End If
  52.  
  53.     If Msg% = 1 Then Resume Else End
  54.  
  55. End Sub
  56.  
  57.